home *** CD-ROM | disk | FTP | other *** search
- /*****
- *
- * Transformations.c
- * Transformations: Rotation of points in 3-D space.
- * Abridged version for MacTech
- * (Matrix transformations omitted)
- *
- * Alexei Lebedev, October 6, 1992
- *
- *****/
-
- #include "Transformations.h"
- #include "SineTable.h"
- #include "FixedPointMath.h"
-
- /* ------------------------------ */
-
- void ScalePoint(Vector3D *p, Fixed x, Fixed y, Fixed z)
- {
- p->x = Multiply(p->x, x);
- p->y = Multiply(p->y, y);
- p->z = Multiply(p->z, z);
- }
-
- /* ------------------------------ */
-
- void PitchPoint(Vector3D *p, short angle)
- {
- Fixed sin, cos, yPrime, zPrime;
-
- GetTrigValues(angle, &sin, &cos);
- yPrime = Multiply(p->y, cos) - Multiply(p->z, sin);
- zPrime = Multiply(p->y, sin) + Multiply(p->z, cos);
- p->y = yPrime;
- p->z = zPrime;
- }
-
- /* ------------------------------ */
-
- void YawPoint(Vector3D *p, short angle)
- {
- Fixed sin, cos, xPrime, zPrime;
-
- GetTrigValues(angle, &sin, &cos);
- xPrime = Multiply(p->x, cos) + Multiply(p->z, sin);
- zPrime = -Multiply(p->x, sin) + Multiply(p->z, cos);
- p->x = xPrime;
- p->z = zPrime;
- }
-
- /* ------------------------------ */
-
- void RollPoint(Vector3D *p, short angle)
- {
- Fixed sin, cos, xPrime, yPrime;
-
- GetTrigValues(angle, &sin, &cos);
- xPrime = Multiply(p->x, cos) - Multiply(p->y, sin);
- yPrime = Multiply(p->x, sin) + Multiply(p->y, cos);
- p->x = xPrime;
- p->y = yPrime;
- }